package com.qingke.hibernate.dao;

import java.util.List;

import org.hibernate.Session;
import org.hibernate.query.Query;

import com.qingke.hibernate.bean.Major;

public class MajorDAO extends SystemDAO{

	public MajorDAO(Session session) {
		super(session);
	}
	public List<Major> list(){
		Query<Major> query=session.createQuery("from Major",Major.class);
		return query.getResultList();
	}
	public List<Major> getMajorsById(int id){
		Query<Major> query=session.createQuery("from Major where id=:id",Major.class);
		query.setParameter("id",id);
		return query.getResultList();
	}
	public List<Major> getMajorsByCode(String code){
		Query<Major> query=session.createQuery("from Major where code like :code",Major.class);
		query.setParameter("code",code);
		return query.getResultList();
	}
	public List<Major> getMajorsByName(String name){
		Query<Major> query=session.createQuery("from Major where name like :name",Major.class);
		query.setParameter("name",name);
		return query.getResultList();
	}
	public List<Major> getMajorsByCollegeId(int collegeId){
		Query<Major> query=session.createQuery("from Major where collegeId=:collegeId",Major.class);
		query.setParameter("collegeId",collegeId);
		return query.getResultList();
	}
	
}
